package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhAuthority;
import com.laowang.project.system.service.MyCyhAuthorityService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 会员权益Controller
 *
 * @author laowang
 * @date 2023-06-02
 */
@Api(tags = "权益介绍接口")
@RestController
@RequestMapping("/authority")
public class MyCyhAuthorityController extends BaseController {
    @Autowired
    private MyCyhAuthorityService myCyhAuthorityService;

    /**
     * 查询会员权益列表
     */
    @ApiOperation(value = "查询权益介绍列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:authority:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyCyhAuthority myCyhAuthority) {
        startPage();
        List<MyCyhAuthority> list = myCyhAuthorityService.selectMyCyhAuthorityList(myCyhAuthority);
        return getDataTable(list);
    }

    /**
     * 导出会员权益列表
     */
    @ApiOperation(value = "导出权益介绍列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:authority:export')")
    @GetMapping("/export")
    public AjaxResult export(MyCyhAuthority myCyhAuthority) {
        List<MyCyhAuthority> list = myCyhAuthorityService.selectMyCyhAuthorityList(myCyhAuthority);
        ExcelUtil<MyCyhAuthority> util = new ExcelUtil<MyCyhAuthority>(MyCyhAuthority.class);
        return util.exportExcel(list, "authority");
    }

    /**
     * 获取会员权益详细信息
     */
    @ApiOperation(value = "获取权益介绍详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:authority:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhAuthorityService.selectMyCyhAuthorityById(id));
    }

    /**
     * 新增会员权益
     */
    @ApiOperation(value = "新增权益介绍",notes = "")
    @PreAuthorize("@ss.hasPermi('my:authority:add')")
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhAuthority myCyhAuthority) {
        return toAjax(myCyhAuthorityService.insertMyCyhAuthority(myCyhAuthority));
    }

    /**
     * 修改会员权益
     */
    @ApiOperation(value = "修改权益介绍",notes = "")
    @PreAuthorize("@ss.hasPermi('my:authority:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhAuthority myCyhAuthority) {
        return toAjax(myCyhAuthorityService.updateMyCyhAuthority(myCyhAuthority));
    }

    /**
     * 删除会员权益
     */
    @ApiOperation(value = "删除权益介绍",notes = "")
    @PreAuthorize("@ss.hasPermi('my:authority:remove')")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhAuthorityService.deleteMyCyhAuthorityByIds(ids));
    }
}
